/*
 *@(#)RowMapperForComment.java 1.0 Apr 3, 2008
 *Copyright Fution Bai
 *
 */
package codebush.service.support.rowMapper;

import java.util.ArrayList;
import java.util.List;

import org.springframework.jdbc.support.rowset.SqlRowSet;

import codebush.domain.Comment;

/**
 * actually this id a rowMapper for v_commentn.
 * @author Fution Bai
 * @since 1.0
 */
public class RowMapperForComment {

	private static RowMapperForComment rowMapperForComment;
	static {
		rowMapperForComment = new RowMapperForComment();
	}

	public static RowMapperForComment getInstance() {
		return rowMapperForComment;
	}

	private RowMapperForComment() {
		;
	}

	public List<Comment> mapRow(SqlRowSet srs) {
		List<Comment> list = new ArrayList<Comment>();
		while (srs.next()) {
			Comment comment = new Comment();
			comment.setId(srs.getLong("id"));
			comment.setContent(srs.getString("content"));
			comment.setUser_id(srs.getInt("user_id"));
			comment.setPost_time(srs.getDate("post_time"));
			comment.setReward(srs.getInt("reward"));
			comment.setParent_id(srs.getLong("parent_id"));
			comment.setSubject_id(srs.getLong("subject_id"));
			comment.setUser_name(srs.getString(8));
			comment.setPicture((byte[]) srs.getObject(9));
			list.add(comment);
		}
		return list;
	}
}
